package com.uzai.common.enums;

/**
 * @Auther: xiaoyuexl
 * @Date: 2021/8/31 16:23
 * @Description: 红包状态 0未领取 1已领取 2领取中 3作废
 */
public enum RedPackStatusEnum {
    /**
     * 未领取
     */
    UNCLAIMED(0,"未领取"),

    /**
     * 已领取
     */
    RECEIVED(1,"已领取"),

    /**
     * 领取中
     */
    RECEIVING(2,"领取中"),

    /**
     * 作废
     */
    INVALID(3,"作废"),

    /**
     * 作废并返还
     */
    INVALID_REBACK(4,"作废并返还"),

    /**
     * 发送中
     */
    SENDING(5,"发送中"),

    /**
     * 发送失败(目前用于手机版发微信红包，发送失败的情况)
     */
    SEND_FAIL(6,"发送失败")

    ;

    private Integer value;
    private String desc;

    public static final int UNCLAIMED_VALUE = 0;
    public static final int RECEIVED_VALUE = 1;
    public static final int RECEIVING_VALUE = 2;
    public static final int INVALID_VALUE = 3;
    public static final int INVALID_REBACK_VALUE = 4;
    public static final int SEND_FAIL_VALUE = 6;

    RedPackStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static RedPackStatusEnum getById(Integer id) {
        if (id == null) {
            return null;
        }
        for (RedPackStatusEnum type: RedPackStatusEnum.values()) {
            if (type.getValue().intValue() == id) {
                return type;
            }
        }
        return null;
    }
}
